resource used: http://learningtensorflow.com/lesson3/
In [25]:
import os
import matplotlib.image as mpimg
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
In [26]:
print(image.shape)
In [30]:
import matplotlib.pyplot as plt
plt.imshow(image)
plt.show()
In [33]:
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
model = tf.global_variables_initializer()
with tf.Session() as session:
x = tf.transpose(x, perm=[1, 0, 2])
session.run(model)
result = session.run(x)
plt.imshow(result)
plt.show()
In [47]:
import numpy as np
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
height, width, depth = image.shape
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
y = tf.reverse_sequence(x, [width] * (height), seq_axis=1, batch_dim=None)
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
result = session.run(y)
print(result.shape)
plt.imshow(result)
plt.show()
In [6]:
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
height, width, depth = image.shape
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
y = tf.transpose(x, perm=[1, 0, 2])
z = tf.reverse_sequence(y, [height] * (width), seq_axis=1, batch_dim=None)
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
result = session.run(z)
plt.imshow(result)
plt.show()
In [18]:
import numpy as np
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
height, width, depth = image.shape
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
y = tf.reverse_v2 (x, axis=[0], name= None)
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
result = session.run(y)
print(result.shape)
plt.imshow(result)
plt.show()
In [28]:
import numpy as np
import tensorflow as tf
import matplotlib.image as mpimg
import matplotlib.pyplot as plt
import os
# First, load the image again
dir_path = os.getcwd()
filename = dir_path + "\\MarshOrchid.jpg"
image = mpimg.imread(filename)
height, width, depth = image.shape
# Create a TensorFlow Variable
x = tf.Variable(image, name='x')
y = tf.reverse_sequence(x, [round(width/2)] * (height), seq_axis=1, batch_dim=None)
model = tf.global_variables_initializer()
with tf.Session() as session:
session.run(model)
result = session.run(y)
plt.imshow(result)
plt.show()
In [30]:
height, width, depth = result.shape
width = round(width/2)
temp = result[:,0:width,:]
temp_reverse = temp[:,::-1,:]
mirror_image = np.concatenate((temp_reverse,temp), axis=1)
plt.imshow(mirror_image)
plt.show()